package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.common.cardkit.card.BaseGsCard;
import com.huawei.gamebox.service.common.cardkit.node.BaseGsNode;
import com.huawei.gamebox.service.welfare.gift.bean.CombineGiftListCardBean;
import com.huawei.gamebox.service.welfare.gift.card.CombineGiftListCard;
import com.huawei.gamebox.service.welfare.gift.card.HorizonScrollGiftListCard;
import java.util.List;
import o.azb;
import o.cgz;
import o.chy;
import o.chz;
import o.cih;
import o.CollectCheck;
import o.exp$a;
import o.exp$c;
import o.exp$e;
import o.exp$f;
import o.exp.d;
import o.exp.j;
import o.fcs;

public class CombineGiftListLineNode extends BaseGsNode {
    private TextView ʻ = null;
    private chy ˊ;
    private LinearLayout ॱॱ = null;

    public CombineGiftListLineNode(Context context) {
        super(context);
    }

    public int ˏ() {
        return 1;
    }

    public boolean ॱ() {
        return true;
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.weight = 1.0f;
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        cih combineGiftListCard = new CombineGiftListCard(this.ॱ);
        int i = j.ॱͺ;
        if (ˋ()) {
            i = j.ᐝॱ;
        }
        View view = (LinearLayout) from.inflate(i, null);
        if (!ˋ()) {
            azb.ˏ(view, d.ˎ);
        }
        this.ॱॱ = (LinearLayout) view.findViewById(d.ꜟ);
        this.ʻ = (TextView) view.findViewById(d.ꜞ);
        TextView textView = (TextView) view.findViewById(d.ᶥ);
        ˋ(textView);
        if (ˋ()) {
            this.ʻ.setTextColor(this.ॱ.getResources().getColor(exp$c.ʽ));
            textView.setTextColor(this.ॱ.getResources().getColor(exp$c.ˋ));
            ((ImageView) view.findViewById(d.ㆍ)).setImageResource(exp$e.ॱˊ);
        }
        combineGiftListCard.ˎ(view);
        ˊ(combineGiftListCard);
        viewGroup.addView(view, layoutParams);
        return true;
    }

    private void ˋ(TextView textView) {
        textView.setText(this.ॱ.getResources().getString(exp$f.ᐝॱ));
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        this.ˏ = o_chz.ˏ;
        cih ˎ = ˎ(0);
        if (ˎ instanceof CombineGiftListCard) {
            CombineGiftListCard combineGiftListCard = (CombineGiftListCard) ˎ;
            CardBean ˋ = o_chz.ˋ(0);
            if (ˋ instanceof CombineGiftListCardBean) {
                ˋ.ˋˋ(String.valueOf(this.ˏ));
                ˎ((CombineGiftListCardBean) ˋ);
                List ˊ = ((CombineGiftListCardBean) ˋ).ˊ();
                if (CollectCheck.isEmpty(ˊ)) {
                    ˎ.ˉ().setVisibility(8);
                } else {
                    ˎ(combineGiftListCard, ˊ.size());
                    ˎ.ˎ(ˋ, viewGroup);
                    ˎ.ˉ().setVisibility(0);
                }
            } else {
                ˎ.ˉ().setVisibility(8);
            }
        }
        return true;
    }

    private void ˎ(CombineGiftListCardBean combineGiftListCardBean) {
        if (this.ॱॱ != null) {
            if (TextUtils.isEmpty(combineGiftListCardBean.ॱॱ())) {
                this.ॱॱ.setVisibility(8);
            } else {
                this.ॱॱ.setVisibility(0);
            }
        }
        if (this.ʻ != null) {
            this.ʻ.setText(combineGiftListCardBean.v_());
        }
    }

    private void ˎ(CombineGiftListCard combineGiftListCard, int i) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        for (int i2 = 0; i2 < i; i2++) {
            View view = (ViewGroup) from.inflate(j.ᐝ, null);
            BaseGsCard horizonScrollGiftListCard = new HorizonScrollGiftListCard(this.ॱ);
            horizonScrollGiftListCard.ˎ(view);
            combineGiftListCard.ˋ(horizonScrollGiftListCard);
            View ˉ = combineGiftListCard.ˉ();
            if (ˉ instanceof ViewGroup) {
                ˋ(i2, view);
                ((ViewGroup) ˉ).addView(view, layoutParams);
            }
        }
        ˋ(this.ˊ);
    }

    private void ˋ(int i, ViewGroup viewGroup) {
        View imageView = new ImageView(this.ॱ);
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, this.ॱ.getResources().getDimensionPixelSize(exp$a.ᐝॱ));
        layoutParams.topMargin = 0;
        int color = this.ॱ.getResources().getColor(exp$c.ˎ);
        if (i == 0) {
            viewGroup.setPadding(0, 0, 0, 0);
        }
        if (ˋ()) {
            layoutParams.leftMargin = this.ॱ.getResources().getDimensionPixelOffset(exp$a.ᐝ);
            layoutParams.rightMargin = this.ॱ.getResources().getDimensionPixelOffset(exp$a.ˋ);
        } else {
            layoutParams.leftMargin = azb.ˊ(this.ॱ);
            layoutParams.rightMargin = azb.ˏ(this.ॱ);
        }
        imageView.setBackgroundColor(color);
        imageView.setLayoutParams(layoutParams);
        viewGroup.addView(imageView);
    }

    public void ˋ(chy o_chy) {
        int i = 0;
        this.ˊ = o_chy;
        cgz ˊ = ˊ(0);
        if (ˊ instanceof CombineGiftListCard) {
            CombineGiftListCard combineGiftListCard = (CombineGiftListCard) ˊ;
            combineGiftListCard.ˎ(o_chy);
            while (i < combineGiftListCard.ˋ()) {
                BaseGsCard ˊ2 = combineGiftListCard.ˊ(i);
                if (ˊ2 != null) {
                    ˊ2.ॱ(this.ˊ);
                }
                i++;
            }
            OnClickListener o_fcs = new fcs(o_chy, combineGiftListCard, 9);
            combineGiftListCard.ˊ().setOnClickListener(o_fcs);
            combineGiftListCard.ʻ().setOnClickListener(o_fcs);
        }
    }
}
